// web/src/app/(employee)/company-side/page.tsx
import React from 'react';
import {currentUser} from "@/lib/auth";
import {db} from "@/lib/db"
import {DataTable} from "@/app/(employee)/company-side/_components/data-table";
import {columns} from "@/app/(employee)/company-side/_components/columns";

const Page = async () => {
    const user = await currentUser()
    const hr = await db.hr.findFirst({
        where: {
            userId: user?.id,
        },
        include: {
            company: true
        }
    })
    if (!hr) return <div>当前用户不是公司HR账户</div>

    const employees = await db.employee.findMany({
        where: {
            companyId: hr.company.id
        },
        include: {
            company: true,
            hr: true
        }
    })

    return (
        <div className={`p-6`}>
            <DataTable columns={columns} data={employees}/>
        </div>
    );
};

export default Page;